package com.wx.mall.operate.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Component
public class UloadImgConfig implements WebMvcConfigurer {

    @Value("${localhost.file.path}")
    private String filePath;

    /**
     * 虚拟路径配置
     * @param registry
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/upload/**").addResourceLocations("file:"+filePath+"/");
        WebMvcConfigurer.super.addResourceHandlers(registry);
    }

}
